package com.vite.mybatisplus.model;

import com.vite.common.utils.StringUtils;
import lombok.Data;

@Data
public class WhereModel {
   private String whereColumn;
   private String table;
   private Object value;
   private String connectType;
   private String method;

   public static final String METHOD_EQUALS = "=";
   public static final String METHOD_LIKE = "like";
   public static final String CONNECT_AND = "AND";
   public static final String CONNECT_OR = "OR";

   public String getFullTableColumn() {
      if (StringUtils.isEmpty(this.table)) {
         return this.whereColumn;
      }
      return this.table + "." + this.whereColumn;
   }

   public String getSqlString() {
      return String.format(" %s %s %s %s ", this.getConnectType(), this.getFullTableColumn(), this.method, this.value);
   }
}
